//
//  SCRadioListTableCell.m
//  OurMoon
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "SCRadioListTableCell.h"
#import "NightHeader.h"
#import "SCRadioListCollectionViewCell.h"
#import "FitHeader.h"
@implementation SCRadioListTableCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.itemSize = CGSizeMake(120 * FitWidth, 180 * FitHeight);
        flowLayout.minimumLineSpacing = 0.5 * FitHeight;
        flowLayout.minimumInteritemSpacing = 0.5 * FitWidth;
        flowLayout.sectionInset = UIEdgeInsetsMake(10 * FitWidth, 0.5 * FitHeight, 0.5 * FitWidth, 0.5 * FitHeight);
        
        //初始化collectionView
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 375 * FitWidth, 200 * FitHeight) collectionViewLayout:flowLayout];
        //设置代理
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        //设置整页滚动
        _collectionView.pagingEnabled = YES;
        _collectionView.bounces = NO;
        _collectionView.scrollEnabled = NO;
        //
        [_collectionView NightWithType:UIViewColorType2];
        [self addSubview:_collectionView];
        
        [_collectionView registerClass:[SCRadioListCollectionViewCell class] forCellWithReuseIdentifier:@"identifier"];
    }
    return self;
}

- (void)setDataArray:(NSMutableArray *)dataArray
{
    _dataArray = dataArray;
    [_collectionView reloadData];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 3;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SCRadioListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
    cell.radioModel = _dataArray[indexPath.row];
     cell.tnameLabel.textType = [NSNumber numberWithInteger:LabelColorGray];
    [cell.tnameLabel NightWithType:UIViewColorTypeNormal];
    [cell.titleLabel NightWithType:UIViewColorTypeNormal];
    [cell NightWithType:UIViewColorTypeNormal];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"jump" object:_dataArray[indexPath.row]];
   // [self.delegate RadioJumpPLayDetail:_dataArray[indexPath.row]];
}

@end
